<template>
	<view>
		<view class="login_content">
			<view class="logo">
				<image src="../../static/img/logo.png" mode="widthFix"></image>
			</view>
			<view class="login" @click="login">
				微信一键登录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginData: {
					avatarUrl: "",
					nickName: "",
					jscode: "",
				},
			}
		},
		onLoad() {
			//获取数据库对象
			const db = uniCloud.database();
			//调用查询函数
			db.collection("contacts").get().then(res=> {
				this.img = res.result.data
				// console.log(this.img.id);
				this.img.forEach(v=>{
					console.log(v.name);
				})
			})
		},
		methods: {
			login() {
				uni.getUserProfile({
					desc: "注册",
					success: (res) => {
						console.log(res);
						getApp().globalData.loginData.avatarUrl = res.userInfo.avatarUrl
						getApp().globalData.loginData.nickName = res.userInfo.nickName
						uni.switchTab({
							url: "../index/index"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login_content {
		display: flex;
		justify-content: space-around;
		align-items: center;
		flex-direction: column;
		box-sizing: border-box;

		.logo {
			width: 400rpx;
			height: 400rpx;
			// margin: 0 auto;
			padding: 100rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.login {
			width: 50%;
			// margin: 0 auto;
			text-align: center;
			padding: 20rpx;
			background: #3dde8e;
			border-radius: 50rpx;
			color: #fff;
			font-size: 34rpx;
		}
	}
</style>
